package com.mpspboot.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MybatisPlus的配置
 * @author GuoChunbo
 * @create 2021-02-22 9:09
 * @Description: 类的描述
 */
@Configuration  //标识这个类是配置类  应用启动被扫描
//扫描mapper
@MapperScan("com.mpspboot.mapper")
public class MybatisPlusConfig {

    /**
     * 配置分页插件Bean <bean id="" class="" />
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //配置数据库的类型
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
